package com.appistry.storage;


import java.util.List;

import org.apache.commons.httpclient.params.HttpClientParams;

import com.appistry.api.rest.httpcommons.DelayedHttpMethodRetryHandler;
import com.appistry.api.util.Version;

public class StorageManagerClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
//		System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
//		System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", "debug");
		System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

		StorageManager manager = new StorageManager("fabric-admin", "fabric-admin", "192.168.1.55", Version.CLOUDIQ_42);
		manager.getHttpConnectionManagerParams().setConnectionTimeout(3000);		
		manager.getHttpClientParams().setParameter(HttpClientParams.RETRY_HANDLER, new DelayedHttpMethodRetryHandler(2, 2000, true));
		
		
		Storage storage = manager.getStorage();
		
		
		List<File> files = storage.getFiles("/");

		for(File file : files){			
			if(file.isDir()){
				System.out.println("DIR: " + file);				
			}else{
				System.out.println("FILE: " + file);
				System.out.println("  Locations: " + file.getLocations());
			}
		}

	}

}
